#coding=utf-8
__author__ = 'Meteor'

import os,jsonpath

import requests

loginurl = 'http://localhost:9000/sys/login'
cturl = 'http://localhost:9000/main/sell/category/show'
data = {

    "username":"小皮在此",
    "password":"123",
    "role":"member"
}

params ={
    "page":1,
    "categoryId":101
}

s = requests.Session()


# login = s.post(loginurl,data=data)
login = s.request(method='POST',url=loginurl,data=data)
token = jsonpath.jsonpath(login.json(),'$..token')[0]
print(login.json())

headers ={
    "token":token
}


# ct = s.get(cturl,params=params,headers=headers)
# ct = s.request(method='get',url=cturl,params=params,headers=headers)
# print(ct.json())







add = 'http://localhost:9000/main/purchase/pomain/add'
headers ={
    "token":token,
    "Content-Type":"application/json"
}

data= {
    "poId":1,
    "venderCode":11,
    "account":"小皮在此",
    "createTime":"2021-08-19 09:00:00",
    "tipFee":12,"productTotal":35,"payType":1,"prePayFee":30,"status":1,"remark":""
}

rest = s.post(add,json=data,headers=headers)
print(rest.text)